<?php
class Main_Controller extends MY_Controller 
{
   function __construct()
   {
      parent::__construct();
      if(!$this->isLogged()){
          redirect('/login');
      }      
   }
   
   protected  function isLogged(){
          if((isset($_SESSION['usuario']) && $_SESSION['usuario'] == true) || $this->isGoingToPedido()){
                return true;
          }else{
             return false;
          }          
  }
  
   /**
     * Si esta cambiando de contraseña 
     * 
     * @return bool 
     */
    protected function isGoingToPedido(){
        return (get_class($this) == "Login") &&
            (isset($this->uri->segments[2]) && $this->uri->segments[2] == 'toPedido' );
    }
  
    protected function getHeaderData(){
       return  array('noShowTabs'=>false, 'showLogOff' => true,'imageBackground' => false,'bootsrapCSS'=>false,'page'=>$this->uri->segment(1));
   }
}
